package security;

/**
 *
 * @author MONESI
 */
import boundary.EventManager;
import boundary.InviteManager;
import boundary.ParticipantFacade;
import boundary.UserManager;
import entity.Participant;
import java.io.Serializable;
import java.util.List;
import java.util.Vector;
import javax.ejb.EJB;
import javax.inject.Named;
import javax.enterprise.context.SessionScoped;
import javax.inject.Inject;


@Named
@SessionScoped
public class ParticipantBean implements Serializable {
     
      
    @EJB
    private InviteManager im;
    
    @EJB
    private UserManager um;
   
    
    List<Integer> x;
      
    
    Participant participant;

    public ParticipantBean() {
    }
    
     public Participant getParticipant() {
        if (participant == null) {
            participant = new Participant();
        }
        return participant;
    }
    
    

    public void setParticipant (Participant user) {
        this.participant = user;
    }
    
    public String azzeraNotifiche(){
        
            im.azzera(um.getLoggedUser().getEmail());
                   
            return "acceptDecline";
    }
    
    public List<String> partecipanti(int id){
        return im.partecipanti(id);
    }
    
    public void id(){
        im.InvitedId(um.getLoggedUser().getEmail());
    }
    
    public String accetta (int idpar){
        
        im.acceptEventById(um.getLoggedUser().getEmail(), idpar);
        
        return "acceptDecline";
        
    }
    public String rifiuta (int idpar){
        
        im.declineEventById(um.getLoggedUser().getEmail(), idpar);
        
        return "acceptDecline";
        
    }

    public String register() {
        
        participant.setEmail(um.getLoggedUser().getEmail());
        
        //im.Invited(um.getLoggedUser().getEmail());
        
        im.save(participant);
        
        return "invitePage";
    }
    

}